#ifndef SERIALTHREAD_H
#define SERIALTHREAD_H

#include <QtGui>

#include "serialconsole.h"
#include "serialport.h"

class SerialThread : public QThread
{
    Q_OBJECT;
public:
    SerialThread(SerialConsole *con, QObject *parent = 0);
    virtual ~SerialThread();
    void startup(SerialPort *port);
    void stop();
    virtual void run();

    void init(QString port, int baudrate);
    bool open(void);
    bool close(void);


private:
    SerialPort      *serialPort;
    SerialConsole   *serialConsole;

    bool            connected;
    QSocketNotifier *socket;

private slots:
    void            socketUpdate(int handle);

signals:
    void            updateConsole(QByteArray *barry);
    void            updateConsole(SerialPort *port);
    void            updateConsole();
};

#endif // SERIALTHREAD_H
